http://gi.reactor.cc/post/4656118 - законченная версия