updates and if statement optimization