working version with external data