cleaned up the code a litle