moved repetitive code to master