seperated everything into single files and put reusable code in to function; cleaned up code