refactored and added var current_flags
added todo comment