error corrected - works but for memory error