streamlined the code a bit