Refactored a few lines of code