added code conventions and fixed some error