rearranged strucutre to follow mvc principles