updated, debugged