refacored the if statments.