cleaned up the input processing a bunch