bug fixed, basic function completed