added exception handling to user inputs and changed return 0 -> return None