removed some duplicated code