created casAndGet as well as some code reduction