Modify delete node to handle corner cases and implement reverse list