cleaned up, removed duplicated code