bugfix

removing useless checks and rubbish code
bugfix

incorrect placement of statements