added type accessor method
restructuring again. Controller in separate file