Move background-color check in to the if condition