Works but need performance improvement