added errorhandler middleware and migrated routing