implemented everything. did error checking