Removed redundant code
Added error handling for same-ID stages
improved console output clarity