Math

Added a Mathclass and removed code duplication