Removed some unnecessary code duplication