addressing performance issues, cleaning up a bit