better implementation of if*