moved main to top and put input functions together