clean up API implementation
More concise implementation of replaceCurrent
Better implementation of replaceCurrent