Refactored some user code