Removing some duplicate code