updated spec and fixed bugs