moved logic into src to separate from testing