refactor amount code for grades