Removed some duplicated code