fixed issue with duration and added extra checks