Removing some code duplication