Refactor code to include user control