fixes and implemented menu as function