fixed some bugs, magic number etc.