finaly working version of pbp