Fixed it to be constant time, all I needed was to make it else if, not just an if statement.