Cleaned up the input code a little bit