Fixed bug in checking input