fixed the functions and added some UI