added flags handling