working, but with memory issue;