code cleanup, now functioning!