had to replace first attempt, seperating form and function