moved alot of code into model for mvc style