Refactor code for simplicity