fixed multiple bugs