a bit more of logic
merged from local files