Refactoring of the handler's return type and fixed some hlint and warnings.