implemented reverse list using foldLeft