removed some magical numbers and added a couple of helpers