added input checks and quit function