own function for random handling
Clean up main; fixes int detection; add range check