removed redundant code and a little bit of cleanup