Cleaned up my code a little bit to make it more readable