done with c part of lab1. maybe need to refactor