removed extraneus stuff integrated some code