removed useless code

also increased efficiency of other code