exceeding maximum call stck, need to refactor