refactor cloud shadow algo for better re-use