Fixed API Issue and Logic Issue