tail functionality done with rest cases and main method also