Updated with more intelegent bounds on all axis, in addition the code has been cleaned up and made more efficient and documented.