Changed some things up, added apply(Math,x) to fix min/max etc