Added tail function
Updated dependencies
Updated backward loops