Refactored; changed precedence of power operator to correct one