Fix bug and format

Fixed basic function