made the work a bit better
removed dead code