finished for submission as school project - probably still buggy