code fix and removal of uneccessary code