Started to break up into funtions