Fixed issue with reversed elements by prepending stmts instead of appending them