added selfmade min implementation