moved if statement execution code inside brackets