Removing some duplicated code