adjusted main file
implemented most functionality