added boolean checking
reordered methods