simplified input element and made input validation more flexible
minor code fixes and simplified input validation