added console logs for testing and clarity