removed unneeded code and fixed bug