not elegant
solution from web