removing some duplicated logic