added exists check to prevent errors