formating and bug fixing