code optimized

thnx to @kasthack