refactored
refactored random numbers, error handling and package structure