add optional
improve implementation of optional