Cleaned up input processing