refactored the code with Derek :)