added restul logic