refactored transition modified to one general function