removed unnecessary if statements and loops