changed main structure to be more angularish using directives. base