moved code to a logically more meaningful place