refactored a bit of the last commit