added constraints and fixed recursion. Fixed decimal problems too