main bugs fix