fix on call bug and reduce code