merged and fixed bugs