Added create method and refactored some ugly code.