removed some more code repetition